package com.nike.main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.nike.dao.NikeDao;
import com.nike.thread.NikeAppLoginThread;
import com.nike.util.JDBCUtil;

public class NikeAppLoginMain {

	public static void main(String[] args) throws Exception {
		ExecutorService fixedThreadPool = Executors
				.newFixedThreadPool(10);
		 Class.forName("com.mysql.jdbc.Driver");
		 Connection c = DriverManager.getConnection(JDBCUtil.jdbcStr);
		 NikeDao nikedao =  new NikeDao();
		while(true){
			
			 Map<String,String> userMap = nikedao.getUser(c);
//			 System.out.println(userMap.get("username"));
			 if(userMap==null || userMap.size()==0) {
				 Thread.sleep(1000);
				 continue;
			 }
//			JSONObject jObject = IPFactory
//					.getKdByUrl(IPFactory.ZM_IP_HTTPS_URL_1);
//			JSONArray jArray = jObject.getJSONArray("data");
//			
//			int	countInt = jArray.size();
	//		for(int i=0;i<countInt;i++){
//				JSONObject jj = (JSONObject) jArray.get(0);
//				NikeAppLoginThread nikeAppLoginThread = new NikeAppLoginThread(jj,userMap);
				NikeAppLoginThread nikeAppLoginThread = new NikeAppLoginThread(userMap);
//				nikeAppLoginThread.start();
				fixedThreadPool.execute(nikeAppLoginThread);
	//		}
			
//			Thread.sleep(5000);
		}
//		c.close();
	}

}
